﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace Automted_Bank_teller
{
    class payBilssProcess :DatabaseConnection
    {
        public float bill ;
        public float allMoeny;

        public void showBalance()
        {
            cmd.CommandText = "Select balance From Clients Where client_id='" + global_var.G_Client_ID + "'and pin_code='" + global_var.G_Client_PIN_Code + "'";
        }
        public bool get_Balance()
        {
            SqlDataReader selector = cmd.ExecuteReader();
            if (selector.Read())
            {
                global_var.G_Current_Account_balance = float.Parse(selector.GetValue(0).ToString());
                return true;
            }
            else
            {
               
                return false;
            }

        
        }
       
        public void update(float allmoeny)
        {
            cmd.CommandText = "Update Clients Set balance='" + allmoeny + "' Where client_id ='" + global_var.G_Client_ID + "'and pin_code ='" + global_var.G_Client_PIN_Code + "'";
        }

        public int ExecuteQuery()
        {
            bool execute ;
            execute = Convert.ToBoolean(cmd.ExecuteNonQuery());
            if (execute == true)
            {
                return 1;
            }
            else
            {
                return 2;
            }
            
            //  MessageBox.Show(" successfully your balance :" + allMoeny); 
            //}
            //else
            //{
            //    MessageBox.Show("error Occured");
            //}
        }

        
        
        
    }
}
